package online.hxstar.cloud.conmuser.stream.config;

import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Flux;

import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.stream.Stream;

/**
 * Stream 配置
 *
 * @author xinghu
 * @version 1.0
 * @date 2019/11/12 11:28 上午
 */
@Configuration
public class StreamConfig {

	public static void main(String[] args) {
		Flux.just("1", "2", "3").subscribe(System.out::println);
		Flux.fromArray(new Integer[]{1, 2, 3}).subscribe(System.out::println);
		Flux.fromArray(new String[]{"1", "2", "3"}).subscribe(System.out::println);
		Flux.fromStream(Stream.of("1", "2", "3")).subscribe(System.out::println);
		Flux.fromIterable(Arrays.asList("1", "2", "3")).subscribe(System.out::println);
		Flux.empty().subscribe(System.out::println);
		Flux.range(1, 10).subscribe(System.out::println);

		Flux.interval(Duration.of(10, ChronoUnit.SECONDS)).subscribe(System.out::println);

		Flux<Integer> integerFlux = Flux.range(2, 3);
		integerFlux.subscribe(System.out::println);
	}
}
